package CtrLayer;
import ModelLayer.LeaseCollection;
import ModelLayer.MachineCollection;
import java.util.ArrayList;


/**
 * Write a description of class LeaseCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LeaseCtr
{

    /**
     * Constructor for objects of class LeaseCtr
     */
    public LeaseCtr()
    {
        MachineCollection.initialize();
    }
    
    public String create_lease(String return_date, ArrayList<String> ids)
    {
        return LeaseCollection.create_lease(return_date, ids);
    }
    
    public void close_order(String id, boolean recalculate_cost)
    {
        LeaseCollection.close_lease(id, recalculate_cost);
    }
    
    public String return_date_control(String id)
    {
        if(LeaseCollection.is_date_before(id))
        {
            return "before";
        }
        else if(LeaseCollection.is_date_after(id))
        {
            return "after";
        }
        else
        {
            return "now";
        }
    }
    
    public String display_lease(String id)
    {
        return LeaseCollection.display_lease(id);
    }
    
    public String display_open_leases()
    {
        return LeaseCollection.display_open_leases();
    }
    
    public String display_closed_leases()
    {
        return LeaseCollection.display_closed_leases();
    }

    public boolean add_machine(String name, double price_per_month)
    {
        return MachineCollection.add_machine(name, price_per_month);
    }
    
    public void save_data()
    {
        MachineCollection.save_data();
        LeaseCollection.save_data();
    }
    
    public void edit_machine(String id, String name, double price_per_month)
    {
        MachineCollection.edit_machine(id, name, price_per_month);
    }
    
    public boolean delete_machine(String id)
    {
        LeaseCollection.clear_machine(id);
        return MachineCollection.delete_machine(id);
    }
    
    public String display_all_machines()
    {
        return MachineCollection.display_all_machines();
    }
    
    public String display_machine(String id)
    {
        return MachineCollection.display_machine(id);
    }
    
    public boolean is_such_machine_id(String id)
    {
        return MachineCollection.is_such_id(id);
    }
    
    public boolean is_such_lease_id(String id)
    {
        return LeaseCollection.is_such_id(id);
    }
    
    public boolean is_lease_closed(String id)
    {
        return LeaseCollection.is_lease_closed(id);
    }
    
    public boolean is_machine_leased(String id)
    {
        return MachineCollection.is_leased(id);
    }
    
    public boolean is_machine_unfinished(String id)
    {
        return MachineCollection.is_unfinished(id);
    }
    
    public String display_unfinished_machines()
    {
        return MachineCollection.display_unfinished();
    }
    
    public void finish_machine(String id, double price_per_day)
    {
        MachineCollection.finish_machine(id, price_per_day);
    }

}
